package br.com.egg.finances.view;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import br.com.egg.finances.business.dao.DAOFactory;
import br.com.egg.finances.dao.BancoDAO;
import br.com.egg.finances.model.Banco;

public class BancoBean extends EntityBean {

	private Banco banco;
	private List<Banco> bancoList;

	public Banco getBanco() {
		return banco;
	}

	public void setBanco(Banco banco) {
		this.banco = banco;
	}

	public List<Banco> getBancoList() {
		if (bancoList == null) {
			BancoDAO bancoDAO = DAOFactory.getBancoDAO();
			setBancoList(bancoDAO.findAll(null));
		}
		return bancoList;
	}
	
	public List<SelectItem> getBancoSelectItems() {
		List<SelectItem> selectItemList = new ArrayList<SelectItem>();

		List<Banco> bancoList = getBancoList();
		for (Banco banco : bancoList) {
			selectItemList.add(new SelectItem(banco.getCdBanco(), banco.getNmBanco()));
		}
		
		return selectItemList;
	}
	
	public void setBancoList(List<Banco> bancoList) {
		this.bancoList = bancoList;
	}

}
